﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Page_AutoUpdate_Login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>登录</title>
    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <link href="../../CSS/patient.css" rel="stylesheet" />
    <link href="../../CSS/public.css" rel="stylesheet" />
    <link href="../../CSS/reset.css" rel="stylesheet" />
    <style>
        .sldd {
            height: 26px;
            padding: 0;
            border: none;
            font-size: 14px;
            width: 100%;
            background: transparent;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
    </style>
</head>
<body>
    <section id="container">

        <p class="page_caption">医疗信息系统</p>

        <section id="patient_edit">
            <form id="patient_edit_form" name="patient_edit_form" method="post">
                <section class="box">
                    <table class="table_data_edit">
                        <tbody>
                            <tr>
                                <th width="80">工号：</th>
                                <td>
                                    <input type="text" id="patientName" name="patients.realName" class="txt" value="" />
                                </td>
                                <td class="required">*</td>
                            </tr>
                            <tr>
                                <th>密码：</th>
                                <td>
                                    <input type="password" id="idNum" name="patients.idCard" class="txt" value="" onkeyup="onkeyups()" />
                                </td>
                                <td class="required">*</td>
                            </tr>
                            <tr>
                                <th>工作台：</th>
                                <td>
                                    <select class="sldd" name='sldd' style='border: 0px; width: 100%;'>
                                        <option value="0">请选择</option>
                                    </select>
                                </td>
                                <td class="required">*</td>
                            </tr>
                        </tbody>
                    </table>
                </section>

                <button type="submit" class="btn">登录</button>

            </form>
        </section>

    </section>




</body>
<script type="text/javascript">

    $(".btn").on("click", function () {
        var patientName = $("#patientName").val();
        var idNum = $("#idNum").val();
        var workStation = $('.sldd option:selected').val();
        $.ajax({
            type: "POST",
            url: "/Handler/AutoUpdateHandler.ashx?action=SetPwd",
            data: { PatientName: patientName, IdNum: idNum, WorkStation: workStation },
            async: false,
            beforeSend: function () {
                var flag = true;
                var msg = '';
                if ($.trim($('#patientName').val()) == '') {
                    flag = false;
                    msg = '请填写工号';
                } else if ($.trim($('#idNum').val()) == '') {
                    flag = false;
                    msg = '请填写密码';
                } else if (workStation <= 0) {
                    flag = false;
                    msg = '请选择工作台';
                }
                if (!flag) {
                    alert(msg);
                };
                return flag;
            },
            success: function (data) {
                data = eval("(" + data + ")");
                if (data.status == "1") {
                    document.forms[0].action = data.info;
                    document.forms[0].submit();
                } else {
                    alert(data.info);
                }
            }
        });
    });

    function slddClick() {
        var patientName = $("#patientName").val();
        var idNum = $("#idNum").val();
        $.ajax({
            type: "POST",
            url: "/Handler/AutoUpdateHandler.ashx?action=GetWorkStation",
            data: { PatientName: patientName, IdNum: idNum },
            async: true,
            beforeSend: function () {
                var flag = true;
                var msg = '';
                if ($.trim($('#patientName').val()) == '') {
                    flag = false;
                    msg = '请填写工号';
                }
                if (!flag) {
                    alert(msg);
                };
                return flag;
            },
            success: function (data) {
                if (data == "" || typeof (eval("(" + data + ")").List) == "undefined") {
                    $(".sldd").html("<option value='-1'>无工作台</option>");
                } else {
                    var html = "";
                    var list = eval("(" + data + ")").List;
                    var result = eval("(" + data + ")").result;
                    if (typeof (list) != "undefined" && result == "success") {
                        for (var i = 0; i < list.length; i++) {
                            var temp = '<option value="{wsid}">{WsName}</option>';
                            html += temp.replace(/{wsid}/, list[i].WSID)
                                .replace(/{WsName}/, list[i].WSName);
                        }
                        $(html).appendTo(".sldd");
                        //$(".sldd").removeAttr("onclick");
                    }
                }
            }
        });
    };

    function onkeyups() {
        slddClick();
    }
</script>
</html>
